 $(function(){ 
	 /*
	  * 合并单元格
	  */
     mergeRows();  
});   


/**
 * 合并单元格
 */
function mergeRows() {  
          
       $(".table").rowspan(2); 
       $(".table").rowspan(3);  
       $(".table").rowspan(4);  
       $(".table").rowspan(5); 
}

/**
 * 删除订单
 */
function deleteOrder(oid){
	layer.confirm('确定删除此订单？',function(index){
		location=$("#basePath").val()+"order/deleteod.html?oid="+oid;
		layer.msg('已删除!',{icon:1,time:1000});
	});
}

/**
 * 取消订单
 */
function cancelOrder(oid){
	layer.confirm('确定取消此订单？',function(index){
		location=$("#basePath").val()+"order/cancelod.html?oid="+oid;
		layer.msg('已取消!',{icon:1,time:1000});
	});
}

function doBack() {
	location.href="http://localhost:8080/bookstore/book/list2.html";
}

var list = [];
function changeStyle(id) {
	if ($('#'+id).hasClass('gou-content')) {
		var index = -1;
		for (var i = 0; i < list.length; i++) {
			if (list[i] == $('#'+id).text()) {
				index = i;
				break;
			} 
		}
		if (index > -1) {
			list.splice(index, 1);
		}
		$('#'+id).removeClass("gou-content");
	} else {
		$('#'+id).addClass("gou-content");
		list.push($('#'+id).text())
	}
}

//提交评价
function subEvaluation() {
	var score = $('.fenshu').text();
	var evaluation = $('#comment').val();
	var impression = list;
	var oid = $('#a-cont').text();
	$.ajax({
		type : "post",
		url : "book/subEvaluation",
		data : {
			"oid" : oid,
			"score" : score,
			"evaluation" : evaluation,
			"impression" : JSON.stringify(impression)
		},
		dataType : 'json',
		cache: false,
		success : function(result) {
			if(result.errorCode = "0") {
				layer.msg('评价成功!',{icon:1,time:1000});
				window.setTimeout("window.location='http://127.0.0.1:8080/bookstore/order/order'",2000); 
			} else {
				layer.msg('评价失败!',{icon:2,time:1000});
			}
		},
		error : function() {
			layer.msg('系统出现异常!',{icon:3,time:1000});
		}
	});
}

//星星评价
function scoreFun(object, opts) {
	var defaults = {
		fen_d : 16,
		ScoreGrade : 10,
		types : [ "很不满意", "差得太离谱，与卖家描述的严重不符，非常不满", "不满意", "部分有破损，与卖家描述的不符，不满意", "一般", "质量一般", "没有卖家描述的那么好", "满意", "质量不错，与卖家描述基本一致还是挺满意的", "非常满意", "质量非常好，与卖家描述的完全一致，非常满意" ],
		nameScore : "fenshu",
		parent : "star_score",
		attitude : "attitude"
	};
	options = $.extend({}, defaults, opts);var countScore = object.find("." + options.nameScore);
	var startParent = object.find("." + options.parent);
	var atti = object.find("." + options.attitude);
	var now_cli;
	var fen_cli;
	var atu;
	var fen_d = options.fen_d;
	var len = options.ScoreGrade;
	startParent.width(fen_d * len);var preA = (5 / len);
	for (var i = 0; i < len; i++) {
		var newSpan = $("<a href='javascript:void(0)'></a>");
		newSpan.css({
			"left" : 0,
			"width" : fen_d * (i + 1),
			"z-index" : len - i
		});newSpan.appendTo(startParent)
	}
	startParent.find("a").each(function(index, element) {
		$(this).click(function() {
			now_cli = index;show(index, $(this))
		});$(this).mouseenter(function() {
			show(index, $(this))
		});$(this).mouseleave(function() {
			if (now_cli >= 0) {
				var scor = preA * (parseInt(now_cli) + 1);
				startParent.find("a").removeClass("clibg");startParent.find("a").eq(now_cli).addClass("clibg");
				var ww = fen_d * (parseInt(now_cli) + 1);
				startParent.find("a").eq(now_cli).css({
					"width" : ww,
					"left" : "0"
				});
				if (countScore) {
					countScore.text(scor)
				}
			} else {
				startParent.find("a").removeClass("clibg");
				if (countScore) {
					countScore.text("")
				}
			}
		})
	});
	function show(num, obj) {
		var n = parseInt(num) + 1;
		var lefta = num * fen_d;
		var ww = fen_d * n;
		var scor = preA * n;
		atu = options.types[parseInt(num)];object.find("a").removeClass("clibg");obj.addClass("clibg");obj.css({
			"width" : ww,
			"left" : "0"
		});countScore.text(scor);atti.text(atu)
	}
}
;